load("//packages/common/locales:index.bzl", "LOCALES", "generate_all_locale_files", "generate_closure_locale_file")
load("//tools:defaults.bzl", "npm_package", "ts_project")

package(default_visibility = ["//visibility:public"])

# This generates the `closure-locale.ts` file through the `generate-locales` tool. Since
# the base locale file is checked-in for Google3, it is additionally stored in a golden location.
generate_closure_locale_file(
    name = "closure_locale_file",
    src = "closure-locale.ts",
)

generate_all_locale_files(
    name = "locale_files",
)

ts_project(
    name = "locales",
    # TODO(devversion): Remove glob for checked-in legacy locale files that haven't been
    # removed in the past (when CLDR has been updated). These can be removed in a major.
    srcs = [file for l in LOCALES for file in [
        "%s.ts" % l,
        "extra/%s.ts" % l,
    ]] + glob(
        [
            "*.ts",
            "extra/*.ts",
        ],
        exclude = ["closure-locale.ts"],
    ),
)

npm_package(
    # TODO(devversion): Remove glob for checked-in legacy locale files that haven't been
    # removed in the past (when CLDR has been updated). These can be removed in a major.
    srcs = ["global/%s.js" % l for l in LOCALES] + [
        ":locales",
        ":locales_types",
    ] + glob(["global/*.js"]),
)
